[906] chore: clear search results when focused outside the Search widget#909
Conversation
🦋 Changeset detectedLatest commit: 76150bb The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Visit the preview URL for this PR (updated for commit 76150bb): https://react-kitchen-sink-dev--pr909-906-clear-search-wid-72atvv6i.web.app (expires Wed, 27 Nov 2024 20:57:07 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 6267897ade2ba783b6db70a53a60fc3946d625e9 |
| renderLabel(label, labelValue) | ||
| } | ||
| notFoundContent={notFoundContentRenderer} | ||
| onBlur={handleClear} |
There was a problem hiding this comment.
shouldn't we expose the onBlur property with EnsembleAction instead of clearing the results.
Clearing means user will lost the previously searched results, this might solve the current problem, but not a general use case
CC: @evshi
There was a problem hiding this comment.
The issue we are trying to solve here is if the value is emptied, then the search results should also be emptied. It doesn't necessarily have anything to do with blur. Ticket for context https://atlashealth.atlassian.net/browse/TRINITY-1461
@justEhmadSaeed what is clearing the search input value?
There was a problem hiding this comment.
@evshi setSearchValue(null) is clearing the input value as that's the default behavior of the Select comp. of antd
There was a problem hiding this comment.
In that case, we should add an effect/fix the effect that syncs the search results with the value. If the value was set to be null, the search results should get cleared @justEhmadSaeed
| useEffect(() => { | ||
| if (!searchValue) { | ||
| setHasCleared(true); | ||
| } | ||
| }, [searchValue]); |
There was a problem hiding this comment.
I don't think we need hasCleared? I think if you use isEmpty instead of isNil and isNull then we can get rid of the extra flag.
There was a problem hiding this comment.
@evshi yeah if we modify the condition to return an empty array if either searchValue is empty or hasCleared is true
Describe your changes
#906
Screenshots [Optional]
Screen.Recording.2024-11-20.at.5.10.23.PM.mov
Issue ticket number and link
Closes #
Checklist before requesting a review
pnpm changeset add